import { Injectable } from "@angular/core";
import { HttpClient, HttpHeaders} from "@angular/common/http";
import qs from "qs";
@Injectable({
  providedIn: "root"
})
export class HttpService {
  constructor(
    public http: HttpClient,
    ) {}
  // let  qs = require("qs")
  //设置一个域名，为了好维护
  public config:any={
    //域名：
    domain:"https://sc.njguochu.com:9212/scgz"
    // domain:"https://sc.yosuo.net:9212/scgz"
  }
  
  websockurl(){
    return 'wss://sc.njguochu.com:9212/wss/scgz/websocket/'
    // return 'wss://sc.yosuo.net:9212/wss/scgz/websocket/'
  }

  upImgurl(){
    return 'https://sc.njguochu.com:9212/img/'
    // return 'https://sc.yosuo.net:9212/img/'
  }
  //请求头和体设置
  private httpOptions = {
    headers: new HttpHeaders({
      "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
    })
  };
  
  
  //封装了一个post请求
  ajaxPost(url: String, json: Object, options: Object) {
    var api = this.config.domain + url;
    return new Promise((resove, reject) => {
      this.http.post(api,qs.stringify(json), options).subscribe(
        response => {
          resove(response);
        },
        error => {
          reject(error);
        }
      );
    });
  }

  imgSrc(){
    // return 'https://sc.njguochu.com:9212/img/'
    return 'https://sc.yosuo.net:9212/img/'
  }

  //请求数据用的
  //登录
  login(params: Object) {
    return this.ajaxPost("/sys/login/loginOn", params, this.httpOptions);
  }
  notarylist(params: Object){
    return this.ajaxPost("/cgz/notaryorder/selectPage", params, this.httpOptions);
  }
  //注册
  register(params: Object){
    return this.ajaxPost("/cgz/user/register", params, this.httpOptions);
  }
  //获取验证码
  get_verify(params: Object){
    return this.ajaxPost("/sys/Sms/Send", params, this.httpOptions);
  }
  //验证码登录
  authCodeApp(params: Object){
    return this.ajaxPost("/sys/login/authCodeApp", params, this.httpOptions);
  }
  //获取上传的材料
  get_uploadCl(params: Object){
    return this.ajaxPost("/sys/annex/queryFileList", params, this.httpOptions);
  }
  //获取上传的材料
  uploadFilesUrl(params: Object){
    return this.ajaxPost("/sys/annex/uploadFilesUrl", params, this.httpOptions);
  }
  //获取公证处
  GET_notaryOffice(params: Object) {
    return this.ajaxPost("/cgz/department/departmentTree", params, this.httpOptions)
  }
  //获取公证事项
  GET_matterTree(params: Object) {
    return this.ajaxPost("/cgz/notarypurpose/selectTree", params, this.httpOptions)
  }
  //获取语言
  getLanguage(params: Object){
    return this.ajaxPost("/sys/countryLanguage/selectAll", params, this.httpOptions)
  }
  //获取国家
  getCountry(params: Object){
    return this.ajaxPost("/sys/countryArea/selectAll", params, this.httpOptions)
  }
  //在线公证创建订单
  addNotaryorder(params: Object){
    return this.ajaxPost("/cgz/notaryorder/add", params, this.httpOptions)
  }
  //视频公证创建订单
  machineAdd(params: Object){
    return this.ajaxPost("/cgz/notaryorder/machineAdd", params, this.httpOptions)
  }
  //根据id获取订单详情
  getNotaryorderById(params: Object){
    return this.ajaxPost("/cgz/notaryorder/getByOrderId", params, this.httpOptions)
  }
  //根据id获取订单时间线
  getNotaryorderTime(params: Object){
    return this.ajaxPost("/cgz/notaryorderlog/getById", params, this.httpOptions)
  }
  //根据公证事项获取公证材料
  getNotaryItem(params: Object){
    return this.ajaxPost("/cgz/notaryitemmodel/selectNotaryItem", params, this.httpOptions)
  }
  //确认信息填写领取方式
  getdoSetState(params: Object){
    return this.ajaxPost("/cgz/notaryorder/doSetState", params, this.httpOptions)
  }
  //上传图片
  upImg(params: Object){
    return this.ajaxPost("/sys/annex/uploadfiles", params, this.httpOptions)
  }
  uploadfiles(params: Object) {
    return this.ajaxPost("/cgz/notaryorder/getByorderId", params, this.httpOptions)
  }
  //中止订单
  repealOrder(params: Object) {
    return this.ajaxPost("/cgz/notaryorder/doSetState", params, this.httpOptions)
  }
  //修改密码的验证
  forgetYzm(params: Object) {
    return this.ajaxPost("/sys/login/authCode", params, this.httpOptions)
  }
  //修改密码
  forgetPwd(params: Object) {
    return this.ajaxPost("/sys/login/forgetPassword", params, this.httpOptions)
  }
  //验证原密码
  verifyPwd(params: Object) {
    return this.ajaxPost("/sys/login/verifyOldPassword", params, this.httpOptions)
  }
  //上传完毕了
  upgood(params: Object) {
    return this.ajaxPost("/cgz/material/addApp", params, this.httpOptions)
  }
  //获取意见类型
  getsuggest(params: Object) {
    return this.ajaxPost("/sys/complaintstype/selectAll", params, this.httpOptions)
  }
  //ADD意见类型
  addsuggest(params: Object) {
    return this.ajaxPost("/cgz/complaint/add", params, this.httpOptions)
  }
  //查询收货地址
  getreceive(params: Object) {
    return this.ajaxPost("/cgz/receivingaddress/selectPage", params, this.httpOptions)
  } 
  //修改头像
  xgheadphoto(params: Object) {
    return this.ajaxPost("/cgz/user/update", params, this.httpOptions)
  }
  getAnnexList(params: Object) {
    return this.ajaxPost("/sys/annex/selectPage", params, this.httpOptions)
  }
  //支付
  doVideologSetState(params: Object) {
    return this.ajaxPost("/cgz/notaryorder/doVideologSetState", params, this.httpOptions)
  }
  
  //扫描登录的二维码
  loginEwm(params: Object) {
    return this.ajaxPost("/sys/login/determine", params, this.httpOptions)
  }

  //在线公证更改状态
  doSetState(params){
    return this.ajaxPost("/cgz/notaryorder/doSetState",params, this.httpOptions)
  }

  /***获取支付宝加密的密文**/
  doSign(params){
    return this.ajaxPost("/alipay/doSign",params, this.httpOptions)
  }

    /***获取微信宝加密的密文**/
    wxPay(params){
      return this.ajaxPost("/cgz/wxpay/MWEBParam",params, this.httpOptions)
    }


  //公证员当前忙
  shutVideoOrder(params){
    return this.ajaxPost("/cgz/notaryorder/doUserStop",params, this.httpOptions)
  }

  //自助公证签名
  doSetSignName(params){
    return this.ajaxPost('/cgz/notaryorder/doSetSignName',params, this.httpOptions)
  }

  // 实名认证，识别身份证
  verified(params){
    return this.ajaxPost('/sys/annex/discern',params, this.httpOptions)
  }
  // 查看是否有身份证
  iDCardImg(params){
    return this.ajaxPost('/cgz/user/iDCardImg',params, this.httpOptions)
  }
  // 在线咨询匹配公证员
  getArtificial(params){
    return this.ajaxPost('/cgz/roomnumber/getArtificial',params, this.httpOptions)
  }

    /**公安联网核查*/ 
    imgContrast(params){
      return this.ajaxPost('/PersonVerify/imgContrast',params, this.httpOptions)
    }
 
  // 查询是否有合同公证
  Que_contract(params){
    return this.ajaxPost('/cgz/notaryorder/queryContract',params, this.httpOptions)
  }

  //查询版本
  Que_version(params){
    return this.ajaxPost('/cgz/appedition/selectNewBy',params, this.httpOptions)
  }
  
}
